//
//  UIBarButtonItem+Category.swift
//  XNWeiBo_Swift
//
//  Created by xunan on 16/6/21.
//  Copyright © 2016年 xunan. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    // 如果在func 前面加class 就相当于OC中 +
    class func createBarButtonItem(imageName: String, target: AnyObject?,action:Selector) -> UIBarButtonItem {
        let rightBtn = UIButton()
        rightBtn.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        rightBtn.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        rightBtn.sizeToFit()
        rightBtn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        return UIBarButtonItem(customView: rightBtn)
    }
}

